home *** CD-ROM | disk | FTP | other *** search
/ Delphi Anthology / aDELPHI.iso / Runimage / Delphi50 / Source / Decision Cube / mxreg.pas < prev    next >
Pascal/Delphi Source File  |  1999-08-11  |  7KB  |  293 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       Borland Delphi Visual Component Library         }
  4. {                                                       }
  5. {       Copyright (c) 1997,99 Inprise Corporation       }
  6. {                                                       }
  7. {*******************************************************}
  8.  
  9. unit MXReg;
  10.  
  11. interface
  12.  
  13. uses
  14.   DsgnIntf, ChartReg, Chart;
  15.  
  16. type
  17.   TDSSChartCompEditor = class(TChartCompEditor)
  18.   public
  19.     procedure Edit; override;
  20.   end;
  21.  
  22.   procedure Register;
  23.  
  24. implementation
  25.  
  26. uses
  27.   SysUtils, Classes, MXGrid, MXPivsrc, MXDB, MXdConst,
  28.   Forms, Graphics, StdCtrls, Comctrls, mxstore, Controls,
  29.   DBTables, mxgraph, BDEConst, mxbutton, mxtables, mxdssqry, mxdimedt, mxdcube,
  30.   EditChar;
  31.  
  32. { TQueryEditor }
  33.  
  34. type
  35.   TDQueryEditor = class(TComponentEditor)
  36.   public
  37.     procedure ExecuteVerb(Index: Integer); override;
  38.     function GetVerb(Index: Integer): string; override;
  39.     function GetVerbCount: Integer; override;
  40.   end;
  41.  
  42.  
  43. procedure TDQueryEditor.ExecuteVerb(Index: Integer);
  44. var
  45.   Query: TQuery;
  46. begin
  47.   Query := Component as TQuery;
  48.   case Index of
  49.     0: ShowDSSQueryEditor(Designer, Query);
  50.   end;
  51. end;
  52.  
  53. function TDQueryEditor.GetVerb(Index: Integer): string;
  54. begin
  55.   case Index of
  56.     0: Result := sQueryVerb1;
  57.   end;
  58. end;
  59.  
  60. function TDQueryEditor.GetVerbCount: Integer;
  61. begin
  62.   Result := 1;
  63. end;
  64.  
  65.   { TSourceEditor }
  66.  
  67. type
  68.   TSourceEditor = class(TComponentEditor)
  69.   public
  70.     procedure ExecuteVerb(Index: Integer); override;
  71.     function GetVerb(Index: Integer): string; override;
  72.     function GetVerbCount: Integer; override;
  73.   end;
  74.  
  75. procedure TSourceEditor.ExecuteVerb(Index: Integer);
  76. var
  77.   Source: TDecisionSource;
  78. begin
  79.   Source := Component as TDecisionSource;
  80.   case Index of
  81.     0:
  82.     begin
  83.       Source.SparseRows := not Source.SparseRows;
  84.       Source.SparseCols := Source.SparseRows;
  85.     end;
  86.   end;
  87. end;
  88.  
  89. function TSourceEditor.GetVerb(Index: Integer): string;
  90. var
  91.   Source: TDecisionSource;
  92. begin
  93.   Source := Component as TDecisionSource;
  94.   case Index of
  95.     0:
  96.     begin
  97.       if Source.SparseRows then
  98.         Result := sSourceVerb0
  99.       else
  100.         Result := sSourceVerb1;
  101.     end;
  102.   end;
  103. end;
  104.  
  105. function TSourceEditor.GetVerbCount: Integer;
  106. begin
  107.   Result := 1;
  108. end;
  109.  
  110.  { TCubeEditor }
  111.  
  112. type
  113.   TCubeEditor = class(TComponentEditor)
  114.   public
  115.     procedure ExecuteVerb(Index: Integer); override;
  116.     function GetVerb(Index: Integer): string; override;
  117.     function GetVerbCount: Integer; override;
  118.   end;
  119.  
  120. procedure TCubeEditor.ExecuteVerb(Index: Integer);
  121. var
  122.   Cube: TDecisionCube;
  123. begin
  124.   Cube := Component as TDecisionCube;
  125.   case Index of
  126.     0: ShowDSSCubeEditor(Designer, Cube);
  127.     1:
  128.     begin
  129.       if (Cube.DataSet is TQuery) then
  130.         ShowDssQueryEditor(Designer,TQuery(Cube.DataSet));
  131.     end;
  132.   end;
  133. end;
  134.  
  135. function TCubeEditor.GetVerb(Index: Integer): string;
  136. begin
  137.   case Index of
  138.     0: Result := SCubeVerb0;
  139.     1: Result := SCubeVerb1;
  140.   end;
  141. end;
  142.  
  143. function TCubeEditor.GetVerbCount: Integer;
  144. var
  145.   Cube: TDecisionCube;
  146. begin
  147.   Cube := Component as TDecisionCube;
  148.   if (Cube.DataSet is TQuery) and not (Cube.DataSet is TDecisionQuery) then
  149.     Result := 2
  150.   else
  151.     Result := 1;
  152. end;
  153.  
  154.   { TDSSChartCompEditor }
  155.  
  156. procedure TDSSChartCompEditor.Edit;
  157. begin
  158.   EditDSSChart(nil, TCustomChart(Component));
  159. end;
  160.  
  161.   { TGridEditor }
  162.  
  163. type
  164.   TGridEditor = class(TComponentEditor)
  165.   public
  166.     procedure ExecuteVerb(Index: Integer); override;
  167.     function GetVerb(Index: Integer): string; override;
  168.     function GetVerbCount: Integer; override;
  169.   end;
  170.  
  171. procedure TGridEditor.ExecuteVerb(Index: Integer);
  172. var
  173.   Grid: TDecisionGrid;
  174. begin
  175.   Grid := Component as TDecisionGrid;
  176.   case Index of
  177.     0: Grid.Totals := not Grid.Totals;
  178.   end;
  179. end;
  180.  
  181. function TGridEditor.GetVerb(Index: Integer): string;
  182. begin
  183.   case Index of
  184.     0: Result := sGridVerb0;
  185.   end;
  186. end;
  187.  
  188. function TGridEditor.GetVerbCount: Integer;
  189. begin
  190.   Result := 1;
  191. end;
  192.  
  193.   { TDecisionGridDimsProperty }
  194.  
  195. type
  196.   TDecisionGridDimsProperty = class(TComponentProperty)
  197.   public
  198.     procedure Edit; override;
  199.     function GetAttributes: TPropertyAttributes; override;
  200.     function GetValue: string; override;
  201.   end;
  202.  
  203. function TDecisionGridDimsProperty.GetAttributes: TPropertyAttributes;
  204. begin
  205.   Result := [paDialog];
  206. end;
  207.  
  208. function TDecisionGridDimsProperty.GetValue: String;
  209. begin
  210.   Result := '(' + TDisplayDims.ClassName + ')';
  211. end;
  212.  
  213. procedure TDecisionGridDimsProperty.Edit;
  214. begin
  215.   ShowDisplayDimEditor(Designer, GetComponent(0) as TDecisionGrid);
  216. end;
  217.  
  218.   { TDimensionMapProperty }
  219.  
  220. type
  221.   TDimensionMapProperty = class(TComponentProperty)
  222.   public
  223.     procedure Edit; override;
  224.     function GetAttributes: TPropertyAttributes; override;
  225.     function GetValue: string; override;
  226.   end;
  227.  
  228. function TDimensionMapProperty.GetAttributes: TPropertyAttributes;
  229. begin
  230.   Result := [paDialog];
  231. end;
  232.  
  233. function TDimensionMapProperty.GetValue: String;
  234. begin
  235.   Result := 'TDimensionMaps';
  236. end;
  237.  
  238. procedure TDimensionMapProperty.Edit;
  239. begin
  240.   ShowDSSCubeEditor(Designer, GetComponent(0)as TDecisionCube);
  241. end;
  242.  
  243.   { TSummaryMapProperty }
  244.  
  245. type
  246.   TSummaryMapProperty = class(TComponentProperty)
  247.   public
  248.     procedure Edit; override;
  249.     function GetAttributes: TPropertyAttributes; override;
  250.     function GetValue: string; override;
  251.   end;
  252.  
  253. function TSummaryMapProperty.GetAttributes: TPropertyAttributes;
  254. begin
  255.   Result := [paDialog];
  256. end;
  257.  
  258. function TSummaryMapProperty.GetValue: String;
  259. begin
  260.   Result := 'TSummaryMaps';
  261. end;
  262.  
  263. procedure TSummaryMapProperty.Edit;
  264. begin
  265.   ShowDSSQueryEditor(Designer, GetComponent(0) as TDecisionQuery);
  266. end;
  267.  
  268.   { Registration }
  269.  
  270. procedure Register;
  271. begin
  272.   RegisterComponents(sComponentTabName, [TDecisionCube, TDecisionQuery,
  273.                      TDecisionSource, TDecisionPivot, TDecisionGrid, TDecisionGraph]);
  274.  
  275.   RegisterNonActiveX([TDecisionCube, TDecisionQuery, TDecisionSource,
  276.                       TDecisionPivot, TDecisionPivot, TDecisionGrid, TDecisionGraph,
  277.                       TCustomDecisionGrid, TCustomDecisionGraph], axrIncludeDescendants);
  278.  
  279.   RegisterComponentEditor(TDecisionQuery, TDQueryEditor);
  280.   RegisterComponentEditor(TDecisionCube, TCubeEditor);
  281.   RegisterComponentEditor(TDecisionSource, TSourceEditor);
  282.   RegisterComponentEditor(TDecisionGrid, TGridEditor);
  283.   RegisterComponentEditor(TDecisionGraph,TDSSChartCompEditor);
  284.  
  285.   RegisterPropertyEditor(TypeInfo(TCollection), TDecisionGrid, 'Dimensions', TDecisionGridDimsProperty);
  286.   RegisterPropertyEditor(TypeInfo(TCollection), TDecisionCube, 'DimensionMap', TDimensionMapProperty);
  287.   RegisterPropertyEditor(TypeInfo(TCollection), TDecisionQuery, 'SummaryMap', TSummaryMapProperty);
  288.   RegisterPropertyEditor(TypeInfo(TDate), nil, '', TDateProperty);
  289. end;
  290.  
  291. end.
  292.  
  293.